/* 调拨单
 */

import { postRequest, getRequest, getDownload, uploadRequest } from '@/lib/axios'

interface TransferOrderApi {
  queryList: (param?: any) => Promise<any>
  detail: (param?: any) => Promise<any>
  create: (param: any) => Promise<any>
  update: (data: any) => Promise<any>
  check: (param: { id: number }) => Promise<any>
  delete: (param: { id: string | number }) => Promise<any>
  exportXlsx: (param?: any) => void
  exportTpl: (param?: any) => void
  importXlsx: (param?: any) => Promise<any>
}

export const transferOrderApi: TransferOrderApi = {
  // 调拨单列表
  queryList: (param) => {
    return getRequest('/transfer_order/list', param)
  },
  //调拨单详情
  detail: (param) => {
    return getRequest(`/transfer_order/${param.id}`, { is_print: param.is_print })
  },
  // 调拨单新增
  create: (param) => {
    return postRequest('/transfer_order/add', param)
  },
  // 调拨单修改
  update: (data) => {
    return postRequest('/transfer_order/edit', data)
  },
  // 调拨单审核
  check: (param) => {
    return postRequest('/transfer_order/check', param)
  },
  // 调拨单删除
  delete: (param) => {
    return postRequest('/transfer_order/del', param)
  },
  // 导出
  exportXlsx: (params) => {
    return getDownload('/transfer_order/exportxlsx', params)
  },
  // 下载模版
  exportTpl: (params) => {
    return getDownload('/transfer_order/exportTpl', params)
  },
  // 导入
  importXlsx: (data) => {
    return uploadRequest('/transfer_order/importXlsx', data)
  }
}
